﻿using MediatR;
using Microsoft.EntityFrameworkCore;
using Process.API.Application.Command.Show;
using Process.Domain;
using Process.ErrorCode;
using Process.Infrastructure.Interface;

namespace Process.API.Application.Handler.Show
{
    public class ProcessTableHandler:IRequestHandler<ProcessTableCommand,APIResult<List<ProcessTable>>>
    {
        IBaseRepository<ProcessTable> proRep;

        public ProcessTableHandler(IBaseRepository<ProcessTable> proRep)
        {
            this.proRep = proRep;
        }

        public async Task<APIResult<List<ProcessTable>>> Handle(ProcessTableCommand request, CancellationToken cancellationToken)
        {
            var m = await proRep.GetAll().ToListAsync();
            return new APIResult<List<ProcessTable>>
            {
                Code = APIEnum.Ok,
                Message="工序显示成功",
                Data= m
            };

        }
    }
}
